﻿using LY.Extension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using Vulcan.Framework.DBConnectionManager;

namespace Sys.API
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            var config = GlobalConfiguration.Configuration;
            var jqueryFormatter = config.Formatters.FirstOrDefault(x => x.GetType() == typeof(System.Web.Http.ModelBinding.JQueryMvcFormUrlEncodedFormatter));
            config.Formatters.Remove(config.Formatters.JsonFormatter);
            config.Formatters.Remove(config.Formatters.XmlFormatter);
            config.Formatters.Remove(config.Formatters.FormUrlEncodedFormatter);
            config.Formatters.Remove(jqueryFormatter);
            AreaRegistration.RegisterAllAreas();
            //默认的数据库管理
            DbConnectionFactory.Default = new SqlConnectionFactory();
            ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory()); 
        }
    }
}